<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*"%>
<%@ page import="org.book.dao.*"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>尚硅谷会员注册页面</title>
<link type="text/css" rel="stylesheet" href="static/css/css.css">
</head>
<body>
	<div class="header">
	<ul>
			<li><a href="BooksServlet">Home</a></li>
			<li><a href="BorrowServlet">借阅信息</a></li>
			<li><a href="UsersServlet">用户信息</a></li>
		</ul>
	
	
	
	<div class="center-right">
            <form action="UsersServlet">
                <input class="input" type="text" name="textName" placeholder="即刻搜索..">
                <input class="input2" type="submit" value="搜索">
            </form>
        </div>
	</div>
	<table class="tab">
		<tr>
			<th>id</th>
			<th>姓名</th>
			<th>卡号</th>
			<th colspan="4">操作</th>
		</tr>

		<%
			Object obj = request.getAttribute("list");
			
			//借阅跳转
			Object flag = request.getSession().getAttribute("book_id");
			
			
			if(obj==null){
				request.getRequestDispatcher("../../index.jsp").forward(request, response);
				return ;
			}
		
			List<UserBean> list = (List<UserBean>)obj;
			
			int pageCurrent = (Integer)(request.getAttribute("pageCurrent"));
			int count = (Integer)(request.getAttribute("count"));
			for (UserBean userBean : list) {
		%>
		<tr>
		 
			
			<td><%=userBean.getUser_id()%></td>
			<td><%=userBean.getUserName()%></td>
			<td><%=userBean.getCardNumber()%></td>
			<td><a href="UserUpdateServlet?no=<%=userBean.getUser_id()%>&pageCurrent2=<%=pageCurrent%>">删除</a></td>
			<td><a href="pages/home/userUpdate.jsp?no=<%=userBean.getUser_id()%>&pageCurrent2=<%=pageCurrent%>">修改</a></td>
			<td><a href="BorrowDetailsServlet?user_id=<%=userBean.getUser_id()%>">借阅详情</a></td>
			<%
				
				String str = "BooksServlet?user_id="+userBean.getUser_id();
				if(flag!=null){
					//如果book_id已存
					int book_id = (int)flag;
					str = "pages/home/borrowPage.jsp?user_id="+userBean.getUser_id() + "&book_id=" + book_id;
				}
			%>
			<td><a href="<%=str %>">借阅</a></td>
		</tr>
		<%
			}
		%>
	</table>
	<div class="boww">
		<ul>
	<li><a href="UsersServlet">首页</a></li>
	<li><a href="UsersServlet?pageCurrent=<%=pageCurrent==1?1:pageCurrent-1%>">上一页</a></li>
	<li><a href="UsersServlet?pageCurrent=<%=pageCurrent==(count+9)/10?(count+9)/10:pageCurrent+1%>">下一页</a></li>
	<li><a href="UsersServlet?pageCurrent=<%=(count+9)/10%>">尾页</a></li>
	<li><a href="pages/home/userUpdate.jsp">添加</a></li>
		</ul>
	</div>


</body>
</html>